<?php
      
// CREATE WIN LIMIT DATES

    
$TIME = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));

$NOW = date("YmdHis",$TIME);

    $daylimitdatestart = substr ($NOW, 0, 8);
    $daylimitdatestart .= "000000";
          echo $daylimitdatestart."<BR>";

    $TIMEdaylimitdateend = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d")+1,date("Y"));

$NOWdaylimitdateend = date("YmdHis",$TIMEdaylimitdateend);

     $daylimitdateend = substr ($NOWdaylimitdateend, 0, 8);
    $daylimitdateend .= "000000";
           echo $daylimitdateend."<BR>";
         $monthlylimitdatestart = substr ($NOW, 0, 6);
    $monthlylimitdatestart .= "01000000"; 
            echo $monthlylimitdatestart."<BR>";
    
    $TIMEmonthlylimitdateend = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m")+1, date("d"),date("Y"));

$NOWmonthlylimitdateend = date("YmdHis",$TIMEmonthlylimitdateend);

     $monthlylimitdateend = substr ($NOWmonthlylimitdateend, 0, 6);
    $monthlylimitdateend .= "01000000";
                     echo $monthlylimitdateend."<BR>";
    $jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
$text_day = (jddayofweek($jd,1));

             echo $text_day;
    if ( $text_day == "Monday" ) {
        $day_correct_backwards = -1;
        $day_correct_forwards = 6;
    }  
    if ( $text_day == "Tuesday" ) {
        $day_correct_backwards = -2;
        $day_correct_forwards =5;
    }
    if ( $text_day == "Wednesday" ) {
        $day_correct_backwards = -3;
        $day_correct_forwards = 4;
    }
        if ( $text_day == "Thursday" ) {
        $day_correct_backwards = -4;
        $day_correct_forwards = 3;
    }
    if ( $text_day == "Friday" ) {
        $day_correct_backwards = -5;
        $day_correct_forwards =2;
    }
    if ( $text_day == "Saturday" ) {
        $day_correct_backwards = -6;
        $day_correct_forwards =1;
    }
    if ( $text_day == "Sunday" ) {
        $day_correct_backwards = 0;
        $day_correct_forwards = 7;
    }
    
          echo $day_correct_backwards;
        echo $day_correct_forwards;
$TIMEweeklylimitdatestart = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d")+$day_correct_backwards,date("Y"));

$NOWweeklylimitdatestart = date("YmdHis",$TIMEweeklylimitdatestart);
    
        $weeklylimitdatestart = substr ($NOWweeklylimitdatestart, 0, 8);
    $weeklylimitdatestart .= "000000";

         echo $weeklylimitdatestart."<BR>";
  
  $TIMEweeklylimitdateend = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d")+$day_correct_forwards,date("Y"));

$NOWweeklylimitdateend = date("YmdHis",$TIMEweeklylimitdateend);
    
        $weeklylimitdateend = substr ($NOWweeklylimitdateend, 0, 8);
    $weeklylimitdateend .= "000000";
    echo $weeklylimitdateend."<BR>";
?>
